package spark.demo.sql.traffic
import org.apache.spark.sql.SparkSession
object MonitorFlowAnalyze {
  def main(args: Array[String]): Unit = {
    //构建SparkSession
    val spark=SparkSession.builder()
      .appName("Data2Hive")
      .enableHiveSupport()//开启Hive支持
      .getOrCreate()

    spark.sql("USE traffic_db");
    //统计正常卡口数量
    //思路：monitor_flow_action表中卡口号去重后的数量即为正常卡口数量
    val result=spark.sql("select count(distinct monitor_id) from monitor_flow_action");
    result.show();
  }
}
